import { ElMessage } from 'element-plus';

export interface IResponseType<P = {}> {
    code?: number;
    msg: string;
    data: P;
}

export interface PageVO<T = {}> {
    current?: number;
    total?: number;
    size?: number;
    data?: T[];
}

export interface PageRO {
    size?: number;
    current?: number;
    orders?: Order[];
}

export interface Order {
    field?: string;
    direction?: string;
}

export function success<T>(r: IResponseType<T>, successMsg?: string) {
    if (r.code === 200) {
        ElMessage({
            message: successMsg ? successMsg : r.msg,
            type: 'success'
        });
    } else {
        ElMessage({
            message: r.msg,
            type: 'error'
        });
    }
}
